/*
 * Created on May 19, 2005
 *
 */
package org.mushroomdb.filemanagement.diskspace;

import java.io.File;
import java.io.IOException;

import org.mushroomdb.exception.RDBMSRuntimeException;
import org.mushroomdb.util.Properties;
import org.mushroomdb.util.PropertiesHelper;


/**
 * @author Matias
 *
 */
public class DiskSpaceManagerFactory {
	private static DiskSpaceManager instanceReference;

	/**
	 * getInstance
	 */
	public static DiskSpaceManager getInstance() {
		if (DiskSpaceManagerFactory.instanceReference == null) {
			String fileName = Properties.getProperty(PropertiesHelper.DATA_FILE);
			File dataFile = new File(fileName);
			if (!dataFile.exists()) {
				try {
					dataFile.createNewFile();
				} catch (IOException e) {
					throw new RDBMSRuntimeException(e);
				}
			}
			DiskSpaceManagerFactory.instanceReference = new DiskSpaceManager(dataFile);
		}
		return DiskSpaceManagerFactory.instanceReference;
	}

}
